<template>
  <div :class="flag ? 'cont-item' : 'prod-show'">
    <div
      :class="flag ? 'show-item' : 'prod-items'"
      v-for="item in searchProdPage"
      :key="item.prodId"
      @click="goDetail(item.prodId)"
    >
      <div :class="flag ? 'more-prod-pic' : 'hot-imagecont'">
        <img :class="flag ? 'more-pic' : 'hotsaleimg'" :src="item.pic" alt="" />
      </div>
      <div :class="flag ? 'prod-text-right' : 'hot-text'">
        <div :class="flag ? 'prod-text' : 'hotprod-text'">
          {{ item.prodName }}
        </div>
        <div :class="flag ? 'cate-prod-info' : 'prod-info'">
          {{ item.praiseNumber }}评价&nbsp;{{ item.prodCommNumber }}好评
        </div>
        <div :class="flag ? 'prod-price' : 'prod-text-info'">
          <span class="symbol">￥</span>
          <span class="big-num">{{ item.price }}</span>
        </div>
      </div>
    </div>
    <div class="empty-list">暂无商品</div>
  </div>
</template>

<script>
import { getLastedProdPage } from "@/services/index";
export default {
  data() {
    return {
      searchProdPage: [],
      flag: false,
      parameter: {
        current: 1,
        size: 10,
      },
    };
  },
  onLoad({ title }) {
    if(title==="限时特购"){
      this.$set(this.parameter, 'current', 3)
    }
    wx.setNavigationBarTitle({
      title: title,
    });
  },
  async created() {
    let res = await getLastedProdPage(this.parameter);
    this.searchProdPage = res.records;
  },
  methods: {
    goDetail(prodId) {
      wx.navigateTo({
        url: `../../category/prod/detail?prodId=${prodId}`,
      });
    },
  },
};
</script>

<style>
.empty-list {
  font-size: 24rpx;
  color: #999;
  text-align: center;
  margin: 100rpx 0;
}
.prod-show {
  background: #fff;
  margin-top: 160rpx;
}
.show-item {
  position: relative;
  display: flex;
  justify-content: start;
  padding: 20rpx;
  border-radius: 20rpx;
  background: #fff;
  margin-bottom: 20rpx;
  box-shadow: 0 16rpx 32rpx 0 rgba(7, 17, 27, 0.05);
}
.more-prod-pic {
  text-align: center;
  width: 170rpx;
  height: 170rpx;
  font-size: 0;
}
.more-pic {
  width: 100%;
  height: 100%;
  vertical-align: middle;
}
.prod-text-right {
  margin-left: 20rpx;
  width: 75%;
}
.prod-text {
  margin: 0;
  height: 78rpx;
  font-size: 28rpx;
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: #000;
}
.cate-prod-info {
  font-size: 22rpx;
  color: #999;
  margin: 10rpx 0 20rpx 0;
}
.prod-price {
  font-size: 28rpx;
  color: #eb2444;
  font-family: arial;
}
.prod-items {
  width: 375rpx;
  float: left;
  background: #fff;
  padding-bottom: 20rpx;
  box-sizing: border-box;
  padding: 20rpx 10rpx 10rpx 20rpx;
}
.hot-imagecont {
  border-radius: 8rpx;
  text-align: center;
  font-size: 0;
}
.hot-text {
  margin-top: 20rpx;
}
.hotsaleimg {
  width: 345rpx;
  height: 345rpx;
}
.hotprod-text {
  height: 76rpx;
  font-size: 28rpx;
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: #000;
}
.prod-info {
  font-size: 20rpx;
  color: #777;
  margin-top: 8rpx;
}
.prod-text-info {
  position: relative;
  height: 50rpx;
  line-height: 70rpx;
  font-family: Arial;
}
.price {
  font-family: Arial;
  display: inline-block;
  padding-bottom: 10rpx;
  padding-left: 10rpx;
}
.symbol {
  font-size: 24rpx;
  color: #eb2444;
}
.big-num {
  font-size: 32rpx;
  color: #eb2444;
}
</style>